package com.xquant.system.api.factory;

import com.xquant.common.core.domain.R;
import com.xquant.system.api.SysConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 系统参数服务降级处理
 *
 * @author botao.yu
 */
@Component
public class RemoteSysConfigFallbackFactory implements FallbackFactory<SysConfigService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteSysConfigFallbackFactory.class);

    @Override
    public SysConfigService create(Throwable throwable)
    {
        log.error("系统参数服务调用失败:{}", throwable.getMessage());
        return new SysConfigService()
        {
            @Override
            public String getSysConfig(String configKey)
            {
                return "获取系统参数失败:" + throwable.getMessage();
            }

        };
    }
}
